<%@ page language="java" contentType="text/html; charset=UTF-8" import="com.dw.model.*,java.net.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<html>
<head>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

		<base href="<%=basePath%>">
		<title>学生信息管理系统主界面</title>
		<script type="text/javascript" src="/static/plugins/thumb/js/jqthumb.js"></script>
		<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
		<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	
<%
	if(request.getAttribute("user")==null){
		String username=null;
		String password=null;
		
		Cookie[] cookies=request.getCookies();
		for(int i=0;cookies!=null && i<cookies.length;i++){
			if(cookies[i].getName().equals("user")){
				username=URLDecoder.decode(cookies[i].getValue().split("-")[0],"UTF-8");
				password=URLDecoder.decode(cookies[i].getValue().split("-")[1],"UTF-8");
		 }
		if(username==null){
			username="";
		}
		
		if(password==null){
			password="";
		}
		
		pageContext.setAttribute("username", username);
		pageContext.setAttribute("password", password);
	}
	}
%>
       <script type="text/javascript" src="${pageContext.request.contextPath}/js/login.js"></script>
       
       <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.css" rel="stylesheet">
       
       <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
       
       <script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.js"></script>
       <script type="text/javascript">
         function loadImage(){
	     document.getElementById("randImage").src = "${pageContext.request.contextPath}/image.jsp?"+Math.random(); //Math.random()方法非常重要，它使每次的请求都不同以便重新发送。如果每次的请求都一样，那么不会重新生成页面
         }
      </script>
<style type="text/css">
body {
	padding="0";
	margin="0";
	background-color: #fff;
}
.header {
  width: 1200px;
  
}
.login {
  right: 10px;
  width: 40%;
  border: 1px ;
  height:400px;
  margin-bottom: 15px;
  }
.slider {
  left: 0px;
  width: 60%;
  height:500px;
}
.container {
  max-width: 1200px;
  max-height: 400px;
}
.form-signin {
	height:600px;
	background-color: #fff;
}

.form-signin .form-signin-heading,.form-signin .checkbox {
	margin-bottom: 15px;
}

.form-signin input[type="text"],.form-signin input[type="password"] {
	height: auto;
	margin-bottom: 15px;
}

h1 {
	color: #fff;
	background: #06b;
	padding: 10px;
	font-size: 200%;
	text-align: center;
}
table 
{ 
margin-left: auto; 
margin-right: auto; 
}
.labelError{line-height: 9px; font-size: 10pt; color: #f40000; border: 1px #ffb8b8 solid; padding: 8px 8px 8px 35px; background: url(/StudentManagerWeb/images/error.png) no-repeat; background-color: #fef2f2;}
</style>

</head>
<body>
	<table class="container"   border="1">
	<!-- 第一行 -->
	<tr>
		
		<td class="header" colspan="2">
		<img src="${pageContext.request.contextPath}/images/logo.png"   width=100%  height=100% />
		</td>
		<td></td>
	</tr>
	
	<tr>
	
		<!-- 第二行第一列 -->
		<td class="slider">
						<div id="myCarousel" class="carousel slide" margin-top:0px>
							<!-- 轮播（Carousel）指标 -->
							<ol class="carousel-indicators">
								<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
								<li data-target="#myCarousel" data-slide-to="1"></li>
								<li data-target="#myCarousel" data-slide-to="2"></li>
							</ol>   
							<!-- 轮播（Carousel）项目 -->
							<div class="carousel-inner">
								<div class="item active">
								<img src="${pageContext.request.contextPath}/images/slider1.jpg" alt="First slide">
								</div>
								<div class="item">
								<img src="${pageContext.request.contextPath}/images/slider2.jpg" alt="Second slide">
								</div>
								<div class="item">
								<img src="${pageContext.request.contextPath}/images/slider3.jpg" alt="Third slide">
								</div>
							</div>
							<!-- 轮播（Carousel）导航 -->
							<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
							    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
							    
							</a>
							<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
							    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
							</a>
						</div>
						
						<!-- 控制按钮 -->
						<div style="text-align:center;">
							<input type="button" class="btn prev-slide" value="前一张">
							<input type="button" class="btn next-slide" value="下一张">
							<input type="button" class="btn slide-two" value="25教">
							<input type="button" class="btn slide-three" value="中图">
						</div>
						<script>
							$(function(){
								// 初始化轮播
								$(".start-slide").click(function(){
									$("#myCarousel").carousel('cycle');
								});
								// 停止轮播
								$(".pause-slide").click(function(){
									$("#myCarousel").carousel('pause');
								});
								// 循环轮播到上一个项目
								$(".prev-slide").click(function(){
									$("#myCarousel").carousel('prev');
								});
								// 循环轮播到下一个项目
								$(".next-slide").click(function(){
									$("#myCarousel").carousel('next');
								});
								// 循环轮播到某个特定的帧 
								$(".slide-one").click(function(){
									$("#myCarousel").carousel(0);
								});
								$(".slide-two").click(function(){
									$("#myCarousel").carousel(1);
								});
								$(".slide-three").click(function(){
									$("#myCarousel").carousel(2);
								});
							});
						</script>			
		</td>
		<!-- 第二行第二列 -->
		<td>
		<ul id="myTab" class="nav nav-tabs">
				<li class="active"><a href="#home" data-toggle="tab">管理员登录</a></li>
				<li><a href="#ios" data-toggle="tab">管理员注册</a></li>
		</ul>
<div id="myTabContent" class="tab-content">
	<div class="tab-pane fade in active" id="home">
		<form class="form-signin" action="login" method="post" onSubmit="return check()">
						<br><br><br><br><br><br>
						<h2 class="form-signin-heading" align="center">管理员登录</h2>
						<hr>
			
					    <table >
					            <tr>
				                     <td ></td>	            
					                 <td><font color="red">${error }</font></td>
					                 <td></td>	  	  
					            </tr>
					    
					            <tr>
					            
				                     <td align="right">用户名：</td>	            
					                 <td><input type="text" name="username" id="username" class="input" value="${username} "></td>
					                 <td><label class="labelError" id="usernameError"></label></td>	  	  
					                 
					            </tr>
			
					             <tr>
				                     <td align="right">密码：</td>	            
					                 <td><input type="password" name="password" id="password" class="input" value="${password }"></td>
					                 <td><label class="labelError" id="passwordError"></label></td>	  	  
					            </tr>
					            
					            <tr>
				                     <td align="right">验证码：</td>	            
					                 <td><input type="text" name="imageValue" size="50px" id="imageValue" class="input" value="${verifyCode }"></td>
					                 <td><label class="labelError" id="imageValueError"></label></td>	  	  
					            </tr>
					            
					            
					             <tr>
				                     <td ></td>	            
					                 <td>
					                  <img onClick="javascript:loadImage();"  title="换一张试试" id="randImage" 
							          src="${pageContext.request.contextPath}/image.jsp" width="100" height="2" border="1" align="absmiddle"></td>
					                 <td> </td>	  	  
					            </tr>
					            
					             <tr>
				                     <td ></td>	            
					                 <td colspan="2"><label class="checkbox"><input id="remember" name="remember" type="checkbox" value="remember-me">记住用户名和密码 &nbsp;&nbsp;&nbsp;&nbsp;  </label></td>
					                 <td></td>	  	  
					            </tr>
					            
					             <tr>
				                     <td ></td>	      
					                 <td><button type="submit"  class="btn btn-primary">登陆</button> <input type="reset" class="btn btn-primary" value="重写"/></td>
					                 <td></td>	  	  
					            </tr>
					    </table>
								</form>
				</div>
				<div class="tab-pane fade" id="ios">
					<form class="form-signin" action="register" method="post" >
									<br><br><br><br><br><br>
									<h2 class="form-signin-heading" align="center">管理员注册</h2>
								<hr>
							    <table >
					    
					            <tr>
					            
				                     <td align="right">用户名：</td>	            
					                 <td><input type="text" name="username" id="username" class="input" value="${username}"></td>
					                 <td><label class="labelError" id="usernameError"></label></td>	  	  
					                 
					            </tr>
			
					             <tr>
				                     <td align="right">密码：</td>	            
					                 <td><input type="password" name="password" id="password" class="input" value="${password}"></td>
					                 <td><label class="labelError" id="passwordError"></label></td>	  	  
					            </tr>
					            					            
 					             <tr>
				                     <td ></td>	            
					                 <td colspan="2"><font color="red">管理员注册邀请码为：XXX</font></td>
					                 <td></td>	  	  
					            </tr> 
					            <tr>
				                     <td align="right">邀请码：</td>	            
					                 <td><input type="text" name="register_code" size="50px"  value="${register_code}"></td>
					                 <td></td>	  	  
					            </tr>
					            <tr>
				                     <td align="right">验证码：</td>	            
					                 <td><input type="text" name="imageValue" size="50px" id="imageValue" class="input" value="${verifyCode}"></td>
					                 <td><label class="labelError" id="imageValueError"></label></td>	  	  
					            </tr>
					             <tr>
				                     <td ></td>	            
					                 <td>
					                  <img onClick="javascript:loadImage();"  title="换一张试试" id="randImage" 
							          src="${pageContext.request.contextPath}/image.jsp" width="100" height="2" border="1" align="absmiddle"></td>
					                 <td> </td>	  	  
					            </tr>
					            
					             <tr>
				                     <td ></td>	            
					                 <td>
					                 <td> </td>	  	  
					            </tr>
					            
					            
					             <tr>
				                     <td ></td>	      
					                 <td><button type="submit"  class="btn btn-primary">注册</button> <input type="reset" class="btn btn-primary" value="重写"/></td>
					                 <td></td>	  	  
					            </tr>
					    </table>
										</form>
						</div>
					</div>
							</td>
						</tr>
						
						<tr>
						<td></td>
						</tr>
						
						</table>

 
</body>
</html>